package Comprehensive_03;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;

public class Demo2 {
    public static void main(String[] args) {
        /*
            班级里有N个学生
            要求：
            70%的概率随机到女生
            30%的概率随机到男生
            "四糸乃", "时崎狂三", "溪弦", "五河琴里", "七罪", "十香","小鸟游六花"
            "张三", "李四", "王五", "路六", "老八"
         */

        //1111111000 思路
        ArrayList<Integer> list = new ArrayList<>();
        //添加数据
        Collections.addAll(list,1, 1, 1, 1, 1, 1, 1);
        Collections.addAll(list,0, 0, 0);
        //打乱集合
        Collections.shuffle(list);
        Random r = new Random();
        int index = r.nextInt(list.size());
        int number = list.get(index);
        System.out.println(number);

        //创建两个集合分别存储男生和女生的名字
        ArrayList<String> boyList = new ArrayList<>();
        ArrayList<String> girlList = new ArrayList<>();

        Collections.addAll(boyList,"张三", "李四", "王五", "路六", "老八");
        Collections.addAll(girlList,"四糸乃", "时崎狂三", "溪弦", "五河琴里", "七罪", "十香","小鸟游六花");

        //判断此时是从boyList还是从girlList中抽取
        if (number == 1){
            //girlList
            System.out.println(girlList.get(r.nextInt(girlList.size())));
        } else {
            //boyList
            System.out.println(boyList.get(r.nextInt(boyList.size())));
        }

    }
}
